//
//  SettingTableViewCell.m
//  NewProject
//
//  Created by admin on 2017/6/15.
//  Copyright © 2017年 李航飞. All rights reserved.
//

#import "SettingTableViewCell.h"
@interface SettingTableViewCell ()
@property(nonatomic, strong)UIImageView *rightImageView;
@property(nonatomic, strong)UISwitch *newsSwitch;
@property(nonatomic, strong)UIView *lineView;
@end

@implementation SettingTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        if([reuseIdentifier isEqualToString:@"0"]){
            _newsSwitch = [[UISwitch alloc]init];
            _newsSwitch.onTintColor = RGB0X(0xEDEDED);
            _newsSwitch.thumbTintColor = RGB0X(0xFFD601);
            [self.contentView addSubview:_newsSwitch];
        }else{
            _rightImageView = [[UIImageView alloc]init];
            _rightImageView.image = [UIImage imageNamed:@"箭头"];
            [self.contentView addSubview:_rightImageView];
        }
        
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = RGB0X(0x333333);
        _titleLabel.font = FONT(15);
        [self.contentView addSubview:_titleLabel];
        
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = RGB0X(0xEDEDED);
        [self.contentView addSubview:_lineView];
        
        [self createConstraint];
    }
    return self;
}

- (void)createConstraint{
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(14/WIDTH_6_SCALE);
        make.centerY.equalTo(self.contentView.mas_centerY);
    }];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(14/WIDTH_6_SCALE);
        make.right.equalTo(self.contentView.mas_right).offset(-14/WIDTH_6_SCALE);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-1/WIDTH_6_SCALE);
        make.height.mas_equalTo(1/WIDTH_6_SCALE);
    }];
    [_newsSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-14/WIDTH_6_SCALE);
        make.centerY.equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(41/WIDTH_6_SCALE,25/WIDTH_6_SCALE));
    }];
    [_rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-15/WIDTH_6_SCALE);
        make.centerY.equalTo(self.contentView.mas_centerY).offset(0);
    }];

}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
